//package com.pfzy.ui.activity.dragsort;
//
//public class DragAndSwipeCallback extends ItemDragAndSwipeCallback {
//
//    public DragAndSwipeCallback(BaseItemDraggableAdapter adapter) {
//        super(adapter);
//    }
//
//    /**
//     * 重写onChildDraw 防止越界拖动
//     *
//     * @param c
//     * @param recyclerView
//     * @param viewHolder
//     * @param dX
//     * @param dY
//     * @param actionState
//     * @param isCurrentlyActive
//     */
//    @Override
//    public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
//        float topY = viewHolder.itemView.getTop() + dY;
//        float bottomY = topY + viewHolder.itemView.getHeight();
//
//        float leftX = viewHolder.itemView.getLeft() + dX;
//        float rightX = leftX + viewHolder.itemView.getWidth();
//
//        if (topY < 0) {
//            dY = 0;
//        } else if (bottomY > recyclerView.getHeight()) {
//            dY = recyclerView.getHeight() - viewHolder.itemView.getHeight() - viewHolder.itemView.getTop();
//        }
//
//        if (leftX < 0) {
//            dX = viewHolder.itemView.getWidth() - viewHolder.itemView.getRight();
//        } else if (rightX > recyclerView.getWidth()) {
//            dX = recyclerView.getWidth() - viewHolder.itemView.getWidth() - viewHolder.itemView.getLeft();
//        }
//
//        super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
//    }
//
//}